<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="/favicon.ico#" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />
    <title>CloudOS</title>
  </head>

  <body style="margin: 0; padding: 0">
    <noscript>欢迎使用PagePlug😘</noscript>
    <iframe
      id="iframe"
      width="100%"
      height="100%"
      frameborder="0"
      style="display: block; height: 100vh"
    ></iframe>
    <script type="text/javascript">
      const parseConfig = (config) => {
        if (
          config.indexOf("__") === 0 ||
          config.indexOf("$") === 0 ||
          config.indexOf("%") === 0
        )
          return "";
        const result = config.trim();
        if (result.toLowerCase() === "false" || result === "") {
          return false;
        } else if (result.toLowerCase() === "true") {
          return true;
        }
        return result;
      };

      function getQueryObject() {
        const url = location.search; //获取url中"?"符后的字串
        let params = new Object();
        if (url.indexOf("?") != -1) {
          let str = url.substr(1);
          strs = str.split("&");
          for (let i = 0; i < strs.length; i++) {
            params[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
          }
        }
        return params;
      }

      let iframeUrl =
        parseConfig("__PAGEPLUG_APP_URL__") ||
        "http://lowcode.mainlinesit.cloudtogo.local";
      const tmpUrl = new URL(iframeUrl);
      const params = getQueryObject();
      for (let key in params) {
        tmpUrl.searchParams.set(key, params[key]);
      }

      iframeUrl = tmpUrl.toString();

      document.getElementById("iframe").src = iframeUrl;
    </script>
  </body>
</html>
